/**
 * Created by zhuhuijun on 2017-9-2 18:33:19
 */
app.controller('ProductListCtrl', ProductListCtrl);
ProductListCtrl.$inject = ['ngTableService', 'layerService', 'commonService'];
function ProductListCtrl(ngTableService, layerService, commonService) {
    var vm = this;
    vm.init = init;
    vm.search = search;
    vm.add = add;
    vm.submit = submit;
    vm.choiceFile = choiceFile;

    function init() {
        search();
    }

    function search() {
        var searchCriteria = {
            url: "product/list.do",
            orderBy: {id: "asc"}
        }
        vm.tableParam = ngTableService.ajax(searchCriteria);
    }

    function add() {
        layerService.popupModalWindowNoCallback("产品信息新增", $("#addInfo"));
    }

    function submit() {
        commonService.postSend("product/save.do", {product: vm.product})
            .then(function (response) {
                layerService.closeAll();
                search();
            });
    }

    function choiceFile() {
        $("#file").click();
    }

}
